package com.spsyry.pay.conteoller.mq;

import com.spsyry.common.core.domain.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.UUID;
import com.spsyry.pay.constatant.RabbitmqConstantCompany;

@RestController
@Slf4j
@RequestMapping("/mp")
public class RabbitmqSendCompanyController {
    @Autowired
    public RabbitTemplate rabbitTemplate;

    @PostMapping(value = "/send")
    public R send() throws Exception{
        log.info("send...........");
        CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());

        this.rabbitTemplate.convertAndSend(
                RabbitmqConstantCompany.MQ_EXCHANGE_NAME,
                RabbitmqConstantCompany.MQ_ROUTING_KEY,
                "2302A-0909090909",
                correlationData);

        return R.ok();
    };
}
